package com.listen.common;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;


public class PhotosConfigUtils {
	
	public static Map<String,Object> daanMap = new ConcurrentHashMap<String,Object>();
	
	private static Properties properties = System.getProperties();
	
	private static final String PHOTOS_CONFIG_NAME = "photos.properties";
	
	public static void load(){
		System.out.println("init t1 ... "+PHOTOS_CONFIG_NAME);
		try {
			String os = System.getProperty("os.name");
			if(os.toLowerCase().startsWith("win")){  
				properties.load(new FileInputStream(new File("D:\\"+PHOTOS_CONFIG_NAME)));
			}else {
				properties.load(new FileInputStream(new File("/home/config/"+PHOTOS_CONFIG_NAME)));
			}
		} catch (FileNotFoundException e) {
			System.out.println("The config file core-config.properties does not exist.");
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println("Failed to load the settings from the file: core-config.properties");
			e.printStackTrace();
	    }
	}
	
	static {
    	load();
    }
	
    public static String getConfig(String key) {
    	return properties.getProperty(key);
    }
    
    public static void main(String args[]){
    	System.out.println(PhotosConfigUtils.getConfig("123"));
    }
}
